package com.mytransaction.service;

import com.mytransaction.annotation.MyTransactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class OrderService {

    private static final Logger logger = LoggerFactory.getLogger(OrderService.class);

    @MyTransactional // 加上事务注解
    public void createOrder(String orderId) {
        logger.info("执行创建订单操作: {}", orderId);
        if ("fail-order".equalsIgnoreCase(orderId)) {
            // 模拟一个错误
            throw new IllegalArgumentException("订单ID无效，无法创建！");
        }
        logger.info("订单 [{}] 创建成功。", orderId);
    }

    public void queryOrder(String orderId) {
        logger.info("执行查询订单操作: {}", orderId);
    }
}
